package com.longge;

import java.util.Arrays;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-07 03:11
 */
public class MaxIceCream {

    public int maxIceCream(int[] costs, int coins) {
        Arrays.sort(costs);
        int i = 0;
        for (; i < costs.length; i++) {
            coins -= costs[i];
            if (coins == 0) return i + 1;
            if (coins < 0) return i;
        }
        return i;
    }
}
